<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="vue.js"></script>
  <script src="vue-router.js"></script>
  <title>Document</title>
</head>

<body>

  <div id="app">
    <div>
      <router-link to="/">index</router-link>
      <router-link to="/about">about us</router-link>
      <router-link to="/user/all">user</router-link>
    </div>
    <div>
      <router-view></router-view>
    </div>
  </div>

  <script>

    const User = {
      template: `<div>User {{ $route.params.id }}
        <div v-show="$route.params.id=='n1'">这是n1</div>
        <div v-show="$route.params.id=='n2'">这是n2</div>
        <div v-show="$route.params.id=='n3'">这是n3</div>
        <router-view></router-view>
        </div>`,

    }

    var temp = [{
      path: '/',
      component: {
        template: `
      <div>首页</div>`
      }
    },

    {
      path: '/about',
      component: {
        template: `
      <div>关于我们</div>`
      }
    },
    {
      path: '/user/:id',
      component: User,
      children: [
        {
          path: 'pro',
          component: {
            template: `
      <button>首页</button>`
          }
        }
      ]
    }
    ]

    const router = new VueRouter({
      routes: temp

    })


    var vm = new Vue({
      el: '#app',
      router: router,

    })
  </script>
</body>

</html>